package com.vogue.supplymall.order.domain.dao.impl;

import com.vogue.supplymall.common.domain.dto.OrderDetailInfo;
import com.vogue.supplymall.common.domain.dto.SearchOrderInfo;
import com.vogue.supplymall.order.domain.dao.OrderDao;
import com.vogue.supplymall.order.domain.mapper.OrderMapper;
import com.vogue.supplymall.order.domain.model.Order;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * The type Order dao.
 *
 * @aouthor: zhangliang
 * @date: Create in 2018-01-10
 */
@Repository("orderDao")
public class OrderDaoImpl extends BaseDaoImpl<Order, Long> implements OrderDao {
    @Resource
    private OrderMapper orderMapper;

    @Override
    public List<Map<String, Object>> findOrderDetail(OrderDetailInfo detailInfo) {
        return orderMapper.findOrderDetail(detailInfo);
    }
    @Override
    public List<Map<String, Object>> findOrderList(SearchOrderInfo searchOrderInfo) {
    	return orderMapper.findOrderList(searchOrderInfo);
    }
    @Override
    public List<Map<String, Object>> findOrderCount(SearchOrderInfo searchOrderInfo) {
    	return orderMapper.findOrderCount(searchOrderInfo);
    }
	@Override
	public void updateOrderCommentFlag(Long orderId, Long productId, int type) {
		String sql="update order_item_product set commentstate="+type
					+" where orderid="+orderId+" and productid="+productId;
		
		this.update(sql);
		
	}

    @Override
    public Order getOrder(String ordernumber, Long syscodeid) {
        List<Order> order = orderMapper.getOrder(ordernumber, syscodeid);
        if (null != order && order.size() > 0){
            return order.get(0);
        }
        return null;
    }

}
